var xTable = 0;

var hgs_obj = '';

hgs_obj += '<div class="date_mbanner" id="date_mbanner">';
//下面是新样式

hgs_obj += '		<div class="fixed">';
hgs_obj += '			<div class="head">';
hgs_obj += '				<em class="emleft" onclick="btn_date_quit();"><img src="img/fanhui.png" alt="" /></em>';
hgs_obj += '				<span id="div_date_0">选择时间</span><div id="div_date_1" style="display:none;"></div><div id="div_date_2" style="display:none;"></div>';
hgs_obj += '				<em class="emright" onclick="btn_date_submit();">确定</em>';
hgs_obj += '			</div>';
hgs_obj += '			<div class="shijianduan clearfix">';
hgs_obj += '				<span id="GetDateStr_to7">近7天</span>';
//hgs_obj += '				<span id="GetDateStr_to30">近30天</span>';
//hgs_obj += '				<span id="GetDateStr_to13">近13周</span>';
   hgs_obj += '				<span id="GetDateStr_toWeek">本周</span>';
   hgs_obj += '				<span id="GetDateStr_thPrevMonth">上月</span>';
hgs_obj += '				<span id="GetDateStr_toMonth">本月</span>';
hgs_obj += '			</div>';
hgs_obj += '		</div>';
hgs_obj += '		<div class="main_div"></div>';

//上面是新样式

hgs_obj += '<div class="div_input" id="div_input_appointDate" style="border: 0px solid #FFF;">';
hgs_obj += '<div style="width:100%;height:10px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>';
hgs_obj += '</div>';
hgs_obj += '</div>';

//
var hgs_tdstr = '';
hgs_tdstr += '<div style="width:100%;text-align:center;margin:20px 0;"><span id="div_title_table1"></span><span>年</span><span id="div_title_table2"></span>月<span></span></div>';

hgs_tdstr += '<table width="100%" height="100%" border="0" class="cal-container" id="cal-container" style="border-bottom: 1px solid #ccc">';
hgs_tdstr += '<tr>';
hgs_tdstr += '<td colspan="7" width="100%" class="div_span_table_tr">';

hgs_tdstr += '</td>';
hgs_tdstr += '</tr>';
hgs_tdstr += '<tr height="30">';
hgs_tdstr += '<td width="14%" align="center" class="red">日</td>';
hgs_tdstr += '<td width="14%" align="center">一</td>';
hgs_tdstr += '<td width="14%" align="center">二</td>';
hgs_tdstr += '<td width="14%" align="center">三</td>';
hgs_tdstr += '<td width="14%" align="center">四</td>';
hgs_tdstr += '<td width="14%" align="center">五</td>';
hgs_tdstr += '<td width="14%" align="center" class="red">六</td>';
hgs_tdstr += '</tr>';
hgs_tdstr += '<tr>';
hgs_tdstr += '<td colspan="7">';
hgs_tdstr += '<table width="100%" height="100%" border="0" id="day_td">';
hgs_tdstr += '<tr>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}0"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}1"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}2"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}3"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}4"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}5"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}6"></td>';
hgs_tdstr += '</tr>';
hgs_tdstr += '<tr>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}7"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}8"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}9"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}10"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}11"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}12"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}13"></td>';
hgs_tdstr += '</tr>';
hgs_tdstr += '<tr>';
hgs_tdstr += '<td data-xday="{data-xdate}" data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}14"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}15"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}16"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}17"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}18"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}19"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}20"></td>';
hgs_tdstr += '</tr>';
hgs_tdstr += '<tr>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}21"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}22"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}23"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}24"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}25"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}26"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}27"></td>';
hgs_tdstr += '</tr>';
hgs_tdstr += '<tr>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}28"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}29"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}30"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}31"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}32"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}33"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}34"></td>';
hgs_tdstr += '</tr>';
hgs_tdstr += '<tr>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}35"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}36"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}37"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}38"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}39"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}40"></td>';
hgs_tdstr += '<td data-xday="{data-xdate}" class="tdday" width="14%" id="tddayDay{xTable}41"></td>';
hgs_tdstr += '</tr>';
hgs_tdstr += '</table>';
hgs_tdstr += '</td>';
hgs_tdstr += '</tr>';
hgs_tdstr += '</table>';

//+---------------------------------------------------  
//| 取得当前日期所在月的最大天数  
//+---------------------------------------------------  
function DayNumOfMonth(Year, Month) {
	Month--;
	var d = new Date(Year, Month, 1);
	d.setDate(d.getDate() + 32 - d.getDate());
	return(32 - d.getDate());
}

/**
 * 获取当前月的第一天
 */
 function getCurrentMonthFirst(Year, Month) {
 	var date = new Date(Year, Month - 1);
 	date.setDate(1);
 	return date;
 }
/**
 * 获取当前月的最后一天
 */
 function getCurrentMonthLast() {
 	var date = new Date();
 	var currentMonth = date.getMonth();
 	var nextMonth = ++currentMonth;
 	var nextMonthFirstDay = new Date(date.getFullYear(), nextMonth, 1);
 	var oneDay = 1000 * 60 * 60 * 24;
 	return new Date(nextMonthFirstDay - oneDay);
 }

//js删除Array数组中的某个元素
function indexOfs(xobj, val) {
	for(var i = 0; i < xobj.length; i++) {
		if(xobj[i] == val) return i;
	}
	return -1;
};

function removes(xobj, val) {
	var index = indexOfs(xobj, val);
	if(index > -1) {
		xobj.splice(index, 1);
	}
};

//功能介绍：检查是否为日期时间  
function RQcheck(RQ) {
	var date = RQ;
	var result = date.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/);
	if(result === null)
		return false;
	var d = new Date(result[1], result[3] - 1, result[4]);
	return(d.getFullYear() == result[1] && (d.getMonth() + 1) == result[3] && d.getDate() == result[4]);

}

//关闭日历界面
function btn_date_quit() {
	$("#date_mbanner").hide();
}

/* 获取上一个月 
 * 
 * @date 格式为yyyy-mm-dd的日期，如：2014-01-25 
 */
 function getPreMonth(date) {
 	var arr = date.split('-');
	var year = arr[0]; //获取当前日期的年份  
	var month = arr[1]; //获取当前日期的月份  
	var day = arr[2]; //获取当前日期的日  
	var days = new Date(year, month, 0);
	days = days.getDate(); //获取当前日期中月的天数  
	var year2 = year;
	var month2 = parseInt(month) - 1;
	if(month2 == 0) {
		year2 = parseInt(year2) - 1;
		month2 = 12;
	}
	var day2 = day;
	var days2 = new Date(year2, month2, 0);
	days2 = days2.getDate();
	if(day2 > days2) {
		day2 = days2;
	}
	if(month2 < 10) {
		month2 = '0' + month2;
	}
	var t2 = year2 + '-' + month2 + '-' + day2;
	return t2;
}

/** 
 * 获取下一个月 
 * 
 * @date 格式为yyyy-mm-dd的日期，如：2014-01-25 
 */
 function getNextMonth(date) {
 	var arr = date.split('-');
	var year = arr[0]; //获取当前日期的年份  
	var month = arr[1]; //获取当前日期的月份  
	var day = arr[2]; //获取当前日期的日  
	var days = new Date(year, month, 0);
	days = days.getDate(); //获取当前日期中的月的天数  
	var year2 = year;
	var month2 = parseInt(month) + 1;
	if(month2 == 13) {
		year2 = parseInt(year2) + 1;
		month2 = 1;
	}
	var day2 = day;
	var days2 = new Date(year2, month2, 0);
	days2 = days2.getDate();
	if(day2 > days2) {
		day2 = days2;
	}
	if(month2 < 10) {
		month2 = '0' + month2;
	}

	var t2 = year2 + '-' + month2 + '-' + day2;
	return t2;
}



//以下为初始化
var mtDate = new Date(); //获取当前  的今天
var mtyear = mtDate.getFullYear(); //获取完整的年份(4位,1970-????)
var mtmonth = mtDate.getMonth() + 1; //获取当前月份(0-11,0代表1月)
var mtdate = mtDate.getDate(); //获取当前日(1-31)
//var mtday = mtDate.getDay(); //获取当前星期X(0-6,0代表星期天)
//var mtmd = mtDate.toLocaleDateString(); //获取当前日期
//
var hgs_xdaynum = 0;
var hgs_xdatearr = [];

$(function() {
	//开始增加日历控件 的html内容 
	$("body").append(hgs_obj);

	(mtmonth < 10) ? mtmonth = "0" + mtmonth: mtmonth = mtmonth; //加个前缀00
	var tmpfirstday = mtyear + "-" + mtmonth + "-" + "01";

	//alert(tmpfirstday);

	for(var i = 12; i > 0; i--) {

		var tmyDate = new Date(tmpfirstday); //获取当前  的今天
		var tmyear = tmyDate.getFullYear(); //获取完整的年份(4位,1970-????)
		var tmmonth = tmyDate.getMonth() + 1; //获取当前月份(0-11,0代表1月)
		var tmdate = tmyDate.getDate(); //获取当前日(1-31)		

		xTable = i;
		var tmm = tmmonth;
		(tmmonth < 10) ? tmm = "0" + tmmonth: tmm = tmmonth; //加个前缀00

		xstr = hgs_tdstr;
		xstr = xstr.replace(/tddayDay{xTable}/g, "xDay" + tmm + "_");
		xstr = xstr.replace(/div_title_table/g, "xTitle" + tmm + "_");
		xstr = xstr.replace(/{data-xdate}/g, tmyear + "-" + tmm + "-"); //放日期的地方

		$("#div_input_appointDate").append(xstr);
		//alert(tmyDate);
		//alert(tmyear+","+ tmm+","+ mtdate+","+ mtmonth);
		yearMonthDay(tmyear, tmm, mtdate, mtmonth,i); //传入循环的年份、月份、今天、本月、顺序
		//取得上一个月日期
		tmpfirstday = getPreMonth(tmpfirstday);
	}

	//通过日历格子选择日期
	$(".tdday").on("click", function() {
		var tmpday = $(this).attr("data-xday");
		if(!RQcheck(tmpday)) {
			return;
		}
		if(hgs_xdaynum < 2) {

			if($(this).hasClass("active")) {
				hgs_xdaynum--;
				$(this).removeClass("active");
				removes(hgs_xdatearr, tmpday);
			} else {
				hgs_xdatearr.push(tmpday);
				$(this).addClass("active");
				hgs_xdaynum++;
			}
		} else {
			if($(this).hasClass("active")) {
				hgs_xdaynum--;
				$(this).removeClass("active");
				removes(hgs_xdatearr, tmpday);
			}
		}
		$("#div_date_1").html("");
		$("#div_date_2").html("");
		//对日期进行排序
		hgs_xdatearr.sort();
		$("#div_date_1").html(hgs_xdatearr[0]);
		$("#div_date_2").html(hgs_xdatearr[1]);
		//console.log(hgs_xdatearr);
		$("#div_date_0").html($("#div_date_1").html() + " " + $("#div_date_2").html());
		judge_data_value();
		
	});

function yearMonthDay(myear, mmonth, mdate, maxmonth,orderid) {

	$("#xTitle" + mmonth + "_" + "1").html(myear);
	$("#xTitle" + mmonth + "_" + "2").html(mmonth);

	var dayfirst = getCurrentMonthFirst(myear, mmonth);
	var daylastnum = DayNumOfMonth(myear, mmonth);
	var dayfirstday = new Date(dayfirst).getDay(); //判断星期几

	//开始计算每个月的“今天”	
	var todaynum = parseInt(dayfirstday - 1) + parseInt(mdate);

	//清空表格
	for(var i = 0; i < 42; i++) {
		$("#xDay" + mmonth + "_" + (i)).html('');
		$("#xDay" + mmonth + "_" + (i)).css("background-color", "#red");
	}



	//开始写日历
	for(var i = 0; i < daylastnum; i++) {
		var objday = "#xDay" + mmonth + "_" + (parseInt(dayfirstday - 1) + i + 1);
		//console.log(objday);
		$(objday).html(i + 1);
		//console.log(i + 1);

		//写data-xday的每一天
		var objtmp = $(objday).data("xday");
		var tmm = "01";
		((i + 1) < 10) ? tmm = "0" + (i + 1): tmm = (i + 1);
		$(objday).attr("data-xday", objtmp + tmm);

		//开始判断是不是 本月今天
		if((orderid == 12)){
			if(i == (mdate - 1)) {
				console.log(objday);	
				$(objday).css("color", "red"); //当天日期的背景色
				$(objday).html("今天");
			}
			if(i > (mdate - 1)) {
				$(objday).css("color", "#FFFFFF"); //当天过后日期的背景色
				$(objday).css("background-color", "#cccccc"); //当天过后日期的背景色
				$(objday).attr("data-xday", "0");
			}

		}

	}

}	

	//---------------------------------------------------
	//通过日历格子选择近7天日期
	$("#GetDateStr_to7").on("click", function() {
		$("#div_date_1").html(GetDateStr(-6));
		$("#div_date_2").html(GetDateStr(0));
		$("#div_date_0").html($("#div_date_1").html() + " " + $("#div_date_2").html());
		hgs_xdatearr.length=0;
		hgs_xdatearr.push(GetDateStr(-6));
		hgs_xdatearr.push(GetDateStr(0));
		hgs_xdaynum=2;
		judge_data_value()
	});
//	$("#GetDateStr_to30").on("click", function () {
//		$("#div_date_1").html(GetDateStr(-29));
//		$("#div_date_2").html(GetDateStr(0));
//		$("#div_date_0").html($("#div_date_1").html() + " " + $("#div_date_2").html());
//		hgs_xdatearr.length = 0;
//		hgs_xdatearr.push(GetDateStr(-29));
//		hgs_xdatearr.push(GetDateStr(0));
//		hgs_xdaynum = 2;
//		judge_data_value()
//	});
//	$("#GetDateStr_to13").on("click", function () {
//		$("#div_date_1").html(GetDateStr(-90));
//		$("#div_date_2").html(GetDateStr(0));
//		$("#div_date_0").html($("#div_date_1").html() + " " + $("#div_date_2").html());
//		hgs_xdatearr.length = 0;
//		hgs_xdatearr.push(GetDateStr(-90));
//		hgs_xdatearr.push(GetDateStr(0));
//		hgs_xdaynum = 2;
//		judge_data_value()
//	});

	//通过日历格子选择本周日期
	 $("#GetDateStr_toWeek").on("click", function() {
	 	var x = getWeekStartAndEnd(0);
	 	$("#div_date_1").html(x[0]);
	 	$("#div_date_2").html(x[1]);
	 	$("#div_date_0").html($("#div_date_1").html() + " " + $("#div_date_2").html());
	 	hgs_xdatearr.length=0;
	 	hgs_xdatearr.push(x[0]);
	 	hgs_xdatearr.push(x[1]);		
	 	hgs_xdaynum=2;
	 	judge_data_value()
	 });

	//通过日历格子选择本月日期
	$("#GetDateStr_toMonth").on("click", function() {
		var x = getMonthStartAndEnd(0);
		$("#div_date_1").html(x[0]);
		$("#div_date_2").html(x[1]);
		hgs_xdatearr.length=0;
		hgs_xdatearr.push(x[0]);
		hgs_xdatearr.push(x[1]);		
		$("#div_date_0").html($("#div_date_1").html() + " " + $("#div_date_2").html());
		hgs_xdaynum=2;
		judge_data_value()
	});

	//通过日历格子选择上月日期
	 $("#GetDateStr_thPrevMonth").on("click", function() {
	 	var x = getMonthStartAndEnd(-1);
	 	$("#div_date_1").html(x[0]);
	 	$("#div_date_2").html(x[1]);
	 	hgs_xdatearr.length=0;
	 	hgs_xdatearr.push(x[0]);
	 	hgs_xdatearr.push(x[1]);		
	 	$("#div_date_0").html($("#div_date_1").html() + " " + $("#div_date_2").html());
	 	hgs_xdaynum=2;
	 	judge_data_value();
	 });

});

//判断近7天，本周，上月，本月等的class
function judge_data_value(){
	$(".tdday").each(function(index,item){
		$(item).removeClass("active");
		if ($(item).html()!=""
			&& ($(item).attr("data-xday") > hgs_xdatearr[0] && $(item).attr("data-xday") < hgs_xdatearr[1])
			|| ($(item).attr("data-xday") == hgs_xdatearr[0] || $(item).attr("data-xday") == hgs_xdatearr[1])
		) {
			$(item).addClass("active");
		}
		// if($(item).attr("data-xday")==hgs_xdatearr[0]){
		// 	$(item).addClass("active");
		// }
		// if($(item).attr("data-xday")==hgs_xdatearr[1]){
		// 	$(item).addClass("active");
		// }		
	});
}

function judge_date_input() {
	var hgs_xdatearr = $("#div_date_1").html();
	var hgs_xdatearr2 = $("#div_date_2").html();

	if((hgs_xdatearr == "") && (hgs_xdatearr2 == "")) {
		hgs_xdatearr = GetDateStr(0); //--------------如果都不选择日期，那么就默认今天
		$("#index-start-date").html(hgs_xdatearr);
		$("#index-end-date").html(hgs_xdatearr);
		$("#index-date-left").show(); //--------------显示
		$("#index-date-right").show();
		$("#index-date-show").html(hgs_xdatearr);

		user_info.look_start_date = hgs_xdatearr;
		user_info.look_end_date = hgs_xdatearr;

	} else if((hgs_xdatearr != "") && (hgs_xdatearr2 != "") && (hgs_xdatearr != hgs_xdatearr2)) {
		$("#index-start-date").val(hgs_xdatearr);
		$("#index-end-date").val(hgs_xdatearr2);
		$("#index-date-left").hide(); //--------------关闭
		$("#index-date-right").hide();
		$("#index-date-show").html(hgs_xdatearr + " 至 " + hgs_xdatearr2);

		user_info.look_start_date = hgs_xdatearr;
		user_info.look_end_date = hgs_xdatearr2;
	} else {
		(hgs_xdatearr != "") ? hgs_xdatearr = hgs_xdatearr: hgs_xdatearr = hgs_xdatearr2;
		$("#index-start-date").val(hgs_xdatearr);
		$("#index-end-date").val(hgs_xdatearr);
		$("#index-date-left").show(); //--------------显示
		$("#index-date-right").show();
		$("#index-date-show").html(hgs_xdatearr);

		user_info.look_start_date = hgs_xdatearr;
		user_info.look_end_date = hgs_xdatearr;

	}

	//专门为筛选日期作的
	$("#em4_time").html($("#index-date-show").html());

	$("#date_mbanner").hide();
}

//获取当前日期yy-mm-dd
//date 为时间对象
function getDateStr3(date) {
	var year = "";
	var month = "";
	var day = "";
	var now = date;
	year = "" + now.getFullYear();
	if((now.getMonth() + 1) < 10) {
		month = "0" + (now.getMonth() + 1);
	} else {
		month = "" + (now.getMonth() + 1);
	}
	if((now.getDate()) < 10) {
		day = "0" + (now.getDate());
	} else {
		day = "" + (now.getDate());
	}
	return year + "-" + month + "-" + day;
}
/** 
 * 获得相对当前周AddWeekCount个周的起止日期 
 * AddWeekCount为0代表当前周   为-1代表上一个周   为1代表下一个周以此类推
 * **/
 function getWeekStartAndEnd(AddWeekCount) {
	//起止日期数组   
	var startStop = new Array();
	//一天的毫秒数   
	var millisecond = 1000 * 60 * 60 * 24;
	//获取当前时间   
	var currentDate = new Date();
	//相对于当前日期AddWeekCount个周的日期
	currentDate = new Date(currentDate.getTime() + (millisecond * 7 * AddWeekCount));
	//返回date是一周中的某一天
	var week = currentDate.getDay();
	//返回date是一个月中的某一天   
	var month = currentDate.getDate();
	//减去的天数   
	var minusDay = week != 0 ? week - 1 : 6;
	//获得当前周的第一天   
	var currentWeekFirstDay = new Date(currentDate.getTime() - (millisecond * minusDay));
	//获得当前周的最后一天
	var currentWeekLastDay = new Date(currentWeekFirstDay.getTime() + (millisecond * 6));
	//添加至数组   
	startStop.push(getDateStr3(currentWeekFirstDay));
	startStop.push(getDateStr3(currentWeekLastDay));

	return startStop;
}
/** 
 * 获得相对当月AddMonthCount个月的起止日期 
 * AddMonthCount为0 代表当月 为-1代表上一个月  为1代表下一个月 以此类推
 * ***/
 function getMonthStartAndEnd(AddMonthCount) {
	//起止日期数组   
	var startStop = new Array();
	//获取当前时间   
	var currentDate = new Date();
	var currentNow = currentDate.getDate();
	var month = currentDate.getMonth() + AddMonthCount;
	if(month < 0) {
		var n = parseInt((-month) / 12);
		month += n * 12;
		currentDate.setFullYear(currentDate.getFullYear() - n);
	}
	currentDate = new Date(currentDate.setMonth(month));
	//获得当前月份0-11   
	var currentMonth = currentDate.getMonth();
	//获得当前年份4位年   
	var currentYear = currentDate.getFullYear();
	//获得上一个月的第一天   
	var currentMonthFirstDay = new Date(currentYear, currentMonth, 1);
	//获得上一月的最后一天   
	if(AddMonthCount==0){
		var currentMonthLastDay = new Date(currentYear, currentMonth, currentNow);
	}else{
		var currentMonthLastDay = new Date(currentYear, currentMonth + 1, 0);
	}
	
	//添加至数组   
	startStop.push(getDateStr3(currentMonthFirstDay));
	startStop.push(getDateStr3(currentMonthLastDay));
	//返回   
	return startStop;
}